<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>科室管理</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<script type="text/javascript" src="js/jquery.js"></script>
		<SCRIPT src="js/color.js" type="text/javascript"></SCRIPT>
		<SCRIPT src="js/jquery.js" type="text/javascript"></SCRIPT>
	<style type="text/css">
	<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}

.STYLE1 {
	font-size: 12px
}

.STYLE3 {
	font-size: 12px;
	font-weight: bold;
}

.STYLE4 {
	color: #03515d;
	font-size: 12px;
}
-->
.boxBorder {
	border: 1px solid green;
}


#addlink,#addlinkb, #addlinkj,#addlinkjb{
	position: absolute;
	width: 400px;
	left: 50%;
	top: 50%;
	margin-left: -200px;
	height: auto;
	z-index: 100;
	background-color: #fff;
	border: 1px #8FA4F5 solid;
	padding: 1px;
}

#addlink h2,#addlinkb h2,#addlinkj h2,#addlinkjb h2{
	height: 25px;
	font-size: 14px;
	background-color:#7bc4d3;
	position: relative;
	padding-left: 10px;
	line-height: 25px;
	color: white;
}

#addlink h2 a,#addlinkj h2 a,#addlinkb h2 a,#addlinkjb h2 a{
	position: absolute;
	right: 5px;
	font-size: 12px;
	color: white;
}

#addlink .form,#addlinkb .jb ,#addlinkj .kb ,#addlinkjb .forms {
	padding-left: 10px;
}

</style>
	<script type="text/javascript">
		function getkeshi(n){
			$.getJSON("type.do?method=getKeshi",{a:Math.random()},function(data){
                            if (data.length != 0) {  
								//清空
								 $("#ks"+n).html("<option value=''>请选择科室</option>");
								 for (i = 0; i < data.length; i++) {
									//追加option
                                    $("#ks"+n).append("<option value=" + data[i].ks_id + ">" + data[i].ks_name + "</option>");
                                }
                                }
                                });
		}
		
		function getkebie(n){
			 var getvalue = $("#ks"+n+" option:selected").val();
                    if (getvalue != null) {
                    
                        $.getJSON("type.do?method=getKebie", {ks_id: getvalue,a:Math.random()}, function(data){
                            if (data.length != 0) {
								//清空
                                $("#kb-list"+n).html("<option value=''>请选择科别</option>");
                                for (i = 0; i < data.length; i++) {
									//追加option
                                    $("#kb-list"+n).append("<option value=" + data[i].kb_id + ">" + data[i].kb_name + "</option>");
                                }
                            }
                        });
                    }
		}
		
		function selectkeshi(ks_id){
			$.getJSON("type.do?method=getKeshi",{a:Math.random()},function(data){
                            if (data.length != 0) {  
								//清空
								 $("#ks3").html("<option value=''>请选择科室</option>");
								 for (i = 0; i < data.length; i++) {
									//追加option
									if(data[i].ks_id==ks_id){
                                    $("#ks3").append("<option value=" + data[i].ks_id + "  selected='true'>" + data[i].ks_name + "</option>");
                                } else {
                                $("#ks3").append("<option value=" + data[i].ks_id + ">" + data[i].ks_name + "</option>");
                                }
                                }
                                }
                                });
		}
		
		function selectkebie(ks_id,kb_id){
		
                        $.getJSON("type.do?method=getKebie", {ks_id: ks_id,a:Math.random()}, function(data){
                            if (data.length != 0) {
								//清空
                                $("#kb-list3").html("<option value=''>请选择科别</option>");
                                for (i = 0; i < data.length; i++) {
									//追加option
									if(data[i].kb_id==kb_id){
                                    $("#kb-list3").append("<option value='" + data[i].kb_id + "' selected='true'>" + data[i].kb_name + "</option>");
									} else {
									$("#kb-list3").append("<option value=" + data[i].kb_id + ">" + data[i].kb_name + "</option>");
									}
                                }
                            }
                        });
		}
		
		function edit(ks_id,kb_id,b_id,b_name,b_symptom){
			addlinkjb.style.display="block";
			addlinkjb.style.top="130px";
			addlinkjb.style.left="350px";
			$("#addjb").css("display","block");
			
			selectkeshi(ks_id);		
			selectkebie(ks_id,kb_id);
			$("#jibingId3").val(b_id);
			$("#jibing3").val(b_name);
			$("#zhengzhuang3").val(b_symptom);
		}
		
		function closeAddjb(){
			$("#addjb").css("display","none");
		}
		
		function addKeshi(){
			addlink.style.display="block";
			addlink.style.top="130px";
			addlink.style.left="350px";
			$("#keshi").css("display","block");
		}
		
		function closeKeshi(){
			$("#keshi").css("display","none");
		}
		
		function addKebie(){
			addlinkb.style.display="block";
			addlinkb.style.top="130px";
			addlinkb.style.left="350px";
			$("#kebie").css("display","block");
			getkeshi(1);
		}
		function closeKebie(){
			$("#kebie").css("display","none");
		}
		function addJibing(){
			addlinkj.style.display="block";
			addlinkj.style.top="130px";
			addlinkj.style.left="350px";
			$("#jibing").css("display","block");
			getkeshi(2);
		}
		function closeJibing(){
			$("#jibing").css("display","none");
		}
		
		
		function doCheck(){
                        var kb_name = document.AddForm.kb_name.value;   // 科别
                        var ks_name = document.AddForm.ks_name.value;   // 科室
                        var b_name = document.AddForm.b_name.value;   // 病
                        var b_symptom = document.AddForm.b_symptom.value;   // 症状
                        if(ks_name==""){
	                        alert("科室不能为空!");
	                        return false;
                        }
                        
                         if(kb_name==""){
	                        alert("科别不能为空！");
	                        return false;
                        }
                        
                         if(b_name==""){
	                        alert("病不能为空！");
	                        return false;
                        }
                        
                         if(b_symptom==""){
	                         alert("症状不能为空！");
	                        return false;
                        }
                         return true;
                     }
                     
                     
                     function addjbCheck(){
                         b_symptom
                        var ks_id = document.addjbForm.ks_id.value;   // 科别
                        var kb_id = document.addjbForm.kb_id.value;   // 科室
                        var b_name = document.addjbForm.b_name.value;   // 病
                        var b_symptom = document.addjbForm.b_symptom.value;   // 症状
                        if(ks_id==""){
	                        alert("请选择科室!");
	                        return false;
                        }
                        
                         if(kb_id==""){
	                        alert("请选择科别！");
	                        return false;
                        }
                        
                         if(b_name==""){
	                        alert("病不能为空！");
	                        return false;
                        }
                        
                         if(b_symptom==""){
	                         alert("症状不能为空！");
	                        return false;
                        }
                         return true;
                     }
				function kbCheck(){
		 				var kb_name = document.kbForm.kb_name.value;   // 科别
                        var ks_id = document.kbForm.ks_id.value;   // 科室
                        var b_name = document.kbForm.b_name.value;   // 病
                        var b_symptom = document.kbForm.b_symptom.value;   // 症状
                        
		 				if(ks_id==""){
	                         alert("科室不能为空!");
	                        return false;
                        }
                        
                         if(kb_name==""){
	                      alert("科别不能为空！");
	                        return false;
                        }
                        
                         if(b_name==""){
	                        alert("病不能为空！");
	                        return false;
                        }
                        
                         if(b_symptom==""){
	                          alert("症状不能为空！");
	                        return false;
                        }
                         return true;
					}
					
					
					function jbCheck(){
		 				var kb_id = document.jbForm.kb_id.value;   // 科别
                        var ks_id = document.jbForm.ks_id.value;   // 科室
                        var b_name = document.jbForm.b_name.value;   // 病
                        var b_symptom = document.jbForm.b_symptom.value;   // 症状
                        
		 				if(ks_id==""){
	                         alert("科室不能为空!");
	                        return false;
                        }
                        
                         if(kb_id==""){
	                      alert("科别不能为空！");
	                        return false;
                        }
                        
                         if(b_name==""){
	                        alert("病不能为空！");
	                        return false;
                        }
                        
                         if(b_symptom==""){
	                          alert("症状不能为空！");
	                        return false;
                        }
                         return true;
					}
	</script>

	</head>
	<body>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td height="30" background="backstage/tab/images//tab_05.gif">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="12" height="30">
								<img src="backstage/tab/images//tab_03.gif" width="12"
									height="30" />
							</td>
							<td>
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td width="46%" valign="middle">
											<table width="100%" border="0" cellspacing="0"
												cellpadding="0">
												<tr>
													<td width="5%">
														<div align="center">
															<img src="backstage/tab/images//tb.gif" width="16"
																height="16" />
														</div>
													</td>
													<td width="95%" class="STYLE1">
														<span class="STYLE3">你当前的位置</span>：[业务中心]-[科室管理]
													</td>
												</tr>
											</table>
										</td>
										<td width="54%">
											<table border="0" align="right" cellpadding="0"
												cellspacing="0">
												<tr>
													<td width="100">
														<table width="87%" border="0" cellpadding="0"
															cellspacing="0">
															<tr>
															<td colspan="2"><a onclick="addKeshi()"><font size="2" color="black"><span style="cursor:pointer;">【添加科室】</span></font></a></td>
															</tr>
														</table>
													</td>
													<td width="100">
														<table width="90%" border="0" cellpadding="0"
															cellspacing="0">
															<tr>
																<td colspan="2"><a onclick="addKebie()"><font size="2" color="black"><span style="cursor:pointer;">【添加科别】</span></font></a></td>
															</tr>
														</table>
													</td>
													
													<td width="100">
														<table width="88%" border="0" cellpadding="0"
															cellspacing="0">
															<tr>
															<td colspan="2"><a onclick="addJibing()"><font size="2" color="black"><span style="cursor:pointer;">【添加疾病】</span></font></a></td>
															</tr>
														</table>
													</td>
												</tr>
											</table>
										</td>
									</tr>
								</table>
							</td>
							<td width="16">
								<img src="backstage/tab/images//tab_07.gif" width="16"
									height="30" />
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="8" background="backstage/tab/images//tab_12.gif">
								&nbsp;
							</td>
							<td>
							<c:if test="${message != null}">
								<table width="100%">
									<tr style="background-color: #87CEFF">
										<td align="center" valign="center" height="30">
											<div>${message}</div>
										</td>
									</tr>
								</table>
							</c:if>
								<table width="100%" border="0" cellpadding="0" cellspacing="1"
									bgcolor="b5d6e6" onmouseover="changeto()" onmouseout="changeback()">
									<tr>
									<td width="5%" height="22"
											background="backstage/tab/images//bg.gif" bgcolor="#FFFFFF">
											<div align="center">
												<span class="STYLE1">编号</span>
											</div>
										</td>
										<td width="20%" height="22"
											background="backstage/tab/images//bg.gif" bgcolor="#FFFFFF">
											<div align="center">
												<span class="STYLE1">科室</span>
											</div>
										</td>
										<td width="20%" height="22"
											background="backstage/tab/images//bg.gif" bgcolor="#FFFFFF">
											<div align="center">
												<span class="STYLE1">科别</span>
											</div>
										</td>
										<td width="20%" background="backstage/tab/images//bg.gif"
											bgcolor="#FFFFFF">
											<div align="center">
												<span class="STYLE1">病名</span>
											</div>
										</td>
										<td width="20%" background="backstage/tab/images//bg.gif"
											bgcolor="#FFFFFF">
											<div align="center">
												<span class="STYLE1">症状</span>
											</div>
										</td>
										<td width="15%" height="22"
											background="backstage/tab/images//bg.gif" bgcolor="#FFFFFF"
											class="STYLE1">
											<div align="center">
												基本操作
											</div>
										</td>
									</tr>
									<c:forEach items="${allDisease}" var="list" varStatus="i">
										<tr>
										<td height="20" bgcolor="#FFFFFF">
												<div align="center">
													<span class="STYLE1">${i.index }</span>
												</div>
											</td>
											<td height="20" bgcolor="#FFFFFF">
												<div align="center">
													<span class="STYLE1">${list.ks_name }</span>
												</div>
											</td>
											<td height="20" bgcolor="#FFFFFF">
												<div align="center">
													<span class="STYLE1">${list.kb_name }</span>
												</div>
											</td>
											<td bgcolor="#FFFFFF">
												<div align="center">
													<span class="STYLE1">${list.b_name }</span>
												</div>
											</td>
											<td bgcolor="#FFFFFF">
												<div align="center">
													<span class="STYLE1">${list.b_symptom }</span>
												</div>
											</td>
											<td height="20" bgcolor="#FFFFFF">
												<div align="center">
													<span class="STYLE4">
													<img src="backstage/tab/images//edt.gif" width="16" height="16" />
												<a onclick="edit(${list.ks_id},${list.kb_id},${list.b_id },'${list.b_name }','${list.b_symptom}')"><span style="cursor:pointer;">编辑</span></a>
												<img src="backstage/tab/images//del.gif" width="16" height="16" />
													<a href="type.do?method=deleteDisease&b_id=${list.b_id }" onclick='return confirm("确定删除 "+${i.index}+" 号疾病")' />删除</a>
													</span>
												</div>
											</td>
										</tr>
									</c:forEach>
								</table>
							</td>
							<td width="8"
								background="backstage/tab/backstage/tab/images///tab_15.gif">
								&nbsp;
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td height="35"
					background="backstage/tab/backstage/tab/images///tab_19.gif">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="12" height="35">
								<img src="backstage/tab/images/tab_18.gif" width="12"
									height="35" />
							</td>
							<td>
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>

										<td>
											<table width="100%" border="0" cellspacing="0"
												cellpadding="0">
												<tr>
													<td class="STYLE4">
														&nbsp;&nbsp;共有 ${rowCount} 条记录，当前第 ${current}/${pageCount}
														页
													</td>
													<td>
														<form action="type.do?method=allDisease" method="post" >
															<table border="0" align="right" cellpadding="0"
																cellspacing="0">
																<tr>
																	<td width="40">
																		<a href="type.do?method=allDisease&current=1"> <img
																				src="backstage/tab/images/first.gif" width="37"
																				height="15" border="0" /> </a>
																	</td>
																	<td width="45">
																		<a
																			href="type.do?method=allDisease&current=${current-1}">
																			<img src="backstage/tab/images/back.gif" width="43"
																				height="15" border="0" /> </a>
																	</td>
																	<td width="45">
																		<a
																			href="type.do?method=allDisease&current=${current+1}">
																			<img src="backstage/tab/images/next.gif" width="43"
																				height="15" border="0" /> </a>
																	</td>
																	<td width="40">
																		<a
																			href="type.do?method=allDisease&current=${pageCount}">
																			<img src="backstage/tab/images/last.gif" width="37"
																				height="15" border="0" /> </a>
																	</td>

																	<td width="100">
																		<div align="center">
																			<span class="STYLE1">转到第 <input name="current"
																					type="text" size="4"
																					onkeypress="if ((event.keyCode<48 || event.keyCode>57)) {event.returnValue=false};
															if(this.value.length > 4){this.value = 10000}"
																					style="height: 12px; width: 20px; border: 1px solid #999999;" />
																				页 </span>
																		</div>
																	</td>
																	<td width="40">
																		<img src="backstage/tab/images/go.gif" width="37"
																			height="15" onclick="submit()" />
																	</td>
																</tr>
															</table>
														</form>
													</td>
												</tr>
											</table>

										</td>
										<td width="16">
											<img src="backstage/tab/images/tab_20.gif" width="16"
												height="35" />
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				<div  id="kebie" style="display: none">
    <div id="addlinkb" style="width:323px;height:170px;margin:0px auto 0px;padding:1px;border:1px solid #a5b6c8;background-color:#eef3f7;">
    <h2 id="bianji">
						添加科别
				<a href="javascript: closeKebie()">关闭</a>
			</h2>
		<div class="kb">
			<form action="type.do?method=addKebie" method="post" name="kbForm">
				科室：
				<select name="ks_id" id="ks1">
				</select>
				<br />
				科别：
				<input type="text" name="kb_name" />
				<br />
				疾病：
				<input type="text" name="b_name" />
				<br />
				症状：
				<input type="text" name="b_symptom">
				<br/>
				<center>
				<input type="submit" value="添加" onclick="return kbCheck()"/></center>
			</form>
    </div>
    </div>
    </div>
				<div  id="keshi" style="display: none">
    <div id="addlink" style="width:323px;height:170px;margin:0px auto 0px;padding:1px;border:1px solid #a5b6c8;background-color:#eef3f7;">
    <h2 id="bianji">
						添加科室
				<a href="javascript: closeKeshi()">关闭</a>
			</h2>
		<div class="form">
			<form action="type.do?method=addKeshi" method="post" name="AddForm">
				科室：
				<input type="text" name="ks_name" />
				<br />
				科别：
				<input type="text" name="kb_name" />
				<br />
				疾病：
				<input type="text" name="b_name" />
				<br />
				症状：
				<input type="text" name="b_symptom">
				<br/>
				<center>
				<input type="submit" value="添加" onclick="return doCheck()"/></center>
			</form>
    </div>
    </div>
    </div>
				<div  id="jibing" style="display: none">
    <div id="addlinkj" style="width:323px;height:170px;margin:0px auto 0px;padding:1px;border:1px solid #a5b6c8;background-color:#eef3f7;">
    <h2 id="bianji">
						添加疾病
				<a href="javascript: closeJibing()">关闭</a>
			</h2>
		<div class="jb">
			<form action="type.do?method=addJibing" method="post" name="jbForm">
				科室：
				<select name="ks_id" id="ks2" onchange="getkebie(2)" >
				</select>
				<br />
				科别：
				<select name="kb_id" id="kb-list2" ></select>
				<br />
				疾病：
				<input type="text" name="b_name" size="15" />
				<br />
				症状：
				<input type="text" name="b_symptom" size="15">
				<br/>
				<center><input type="submit" value="添加"   onclick="return jbCheck()"/></center>
			</form>
    </div>
    </div>
    </div>
    
				<div  id="addjb" style="display: none">
    			<div id="addlinkjb" style="width:323px;height:170px;margin:0px auto 0px;padding:1px;border:1px solid #a5b6c8;background-color:#eef3f7;">
    			<h2 id="bianji">
						添加疾病
				<a href="javascript: closeAddjb()">关闭</a>
				</h2>
				<div class="forms">
			<form action="type.do?method=updateDisease" method="post" name="addjbForm">
				科室：
				<select name="ks_id" id="ks3" onchange="getkebie(3)" disabled="disabled">
				</select>
				<br />
				科别：
				<select name="kb_id" id="kb-list3" disabled="disabled"></select>
				<br />
				疾病：
				<input type="hidden" name="b_id" size="15" id="jibingId3"/>
				<input type="text" name="b_name" size="15" id="jibing3"/>
				<br />
				症状：
				<input type="text" name="b_symptom" size="15" id="zhengzhuang3">
				<br/>
				<center><input type="submit" value="修改" onclick="return addjbCheck()"/></center>
			</form>
    </div>
    </div>
    </div>
	</body>
</html>
